#!/bin/bash

apt_update()
{
    apt update 
    apt install -y sudo
    #grep -w vi /etc/sudoers >/dev/null
    #if [ $? -ne 0 ] ; then
    #    echo "vi	ALL=(ALL:ALL) ALL" >> /etc/sudoers
    #fi
}

vadduser()
{
    cat /etc/passwd| grep vi > /dev/null
    if [ $? -ne 0 ] ; then
        useradd vi -d /home/vi -m -s /bin/bash -G sudo
        passwd vi
        echo "vi user created ok."
    else
        echo "vi already exist."
    fi
}

install_tool()
{
    apt install -y vim net-tools netcat git cmake
}


if [ "`whoami`"x == "root"x ] ; then
    vadduser
    apt_update
    install_tool
else
    echo "error,current script can only run under root."
fi


